
/**THIS PROGRAM CREATES THE LIST of ZIP CODES and THIER SIZE in 2000*

Raw Data Sources:
-Zip code list, Zip Code geographic size from Census 2000 website

last update to this do-file: 10-4-2016
*/


cd $datafolder

*Read in Zip Code level data (Census)*

import delimited "zipcodedata.txt", clear
destring(zipcode), force replace
drop if zipcode==.

save zipcodedata2000.dta, replace

set more off
infix str state 1-2 zip 3-7  pop 67-75  housing 76-84 land 113-124 using "zcta5.txt", clear
drop if zip==.
rename zip zipcode
**some in multiple states are split into state portions
foreach n in pop housing land {
bysort zipcode: egen total`n'=total(`n')
}
**for those in multiple, pick state with largest population
gen frac_pop=pop/totalpop
gsort zipcode -frac_pop
by zipcode: gen n=_n
keep if n==1
keep total* zip state
save "zipcodedata2000_2.dta", replace


